package com.qfedu.sign.consumer.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.qfedu.sign.common.vo.R;
import com.qfedu.sign.consumer.service.SignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/sign/")
public class SignApi {
    @Autowired
    private SignService signService;

    @PostMapping("addsign.do")
    public R sign(@RequestParam int uid){
        return signService.sign(uid);
    }
    //添加熔断机制
    @SentinelResource(value = "checksign",fallback = "checkError")
    @GetMapping("checksign.do")
    public R check(@RequestParam int uid){
        return signService.check(uid);
    }
    //降级方法，如果保护的方法出现异常或者超时，就会执行本降级方法
    public R checkError(int uid){
        return R.fail("熔断降级");
    }

    @GetMapping("signlist.do")
    public R list(@RequestParam int uid){
        return signService.list(uid);
    }
}
